package com.ruoyi.jjyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jjyh.domain.JjyhUservalidays;
import com.ruoyi.jjyh.service.IJjyhUservalidaysService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户有效期变动记录Controller
 * 
 * @author ruoyi
 * @date 2020-12-02
 */
@Controller
@RequestMapping("/jjyh/uservalidays")
public class JjyhUservalidaysController extends BaseController
{
    private String prefix = "jjyh/uservalidays";

    @Autowired
    private IJjyhUservalidaysService jjyhUservalidaysService;

    @RequiresPermissions("jjyh:uservalidays:view")
    @GetMapping()
    public String uservalidays()
    {
        return prefix + "/uservalidays";
    }

    /**
     * 查询用户有效期变动记录列表
     */
    @RequiresPermissions("jjyh:uservalidays:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JjyhUservalidays jjyhUservalidays)
    {
        startPage();
        List<JjyhUservalidays> list = jjyhUservalidaysService.selectJjyhUservalidaysList(jjyhUservalidays);
        return getDataTable(list);
    }

    /**
     * 导出用户有效期变动记录列表
     */
    @RequiresPermissions("jjyh:uservalidays:export")
    @Log(title = "用户有效期变动记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JjyhUservalidays jjyhUservalidays)
    {
        List<JjyhUservalidays> list = jjyhUservalidaysService.selectJjyhUservalidaysList(jjyhUservalidays);
        ExcelUtil<JjyhUservalidays> util = new ExcelUtil<JjyhUservalidays>(JjyhUservalidays.class);
        return util.exportExcel(list, "uservalidays");
    }

    /**
     * 新增用户有效期变动记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存用户有效期变动记录
     */
    @RequiresPermissions("jjyh:uservalidays:add")
    @Log(title = "用户有效期变动记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JjyhUservalidays jjyhUservalidays)
    {
        return toAjax(jjyhUservalidaysService.insertJjyhUservalidays(jjyhUservalidays));
    }

    /**
     * 修改用户有效期变动记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        JjyhUservalidays jjyhUservalidays = jjyhUservalidaysService.selectJjyhUservalidaysById(id);
        mmap.put("jjyhUservalidays", jjyhUservalidays);
        return prefix + "/edit";
    }

    /**
     * 修改保存用户有效期变动记录
     */
    @RequiresPermissions("jjyh:uservalidays:edit")
    @Log(title = "用户有效期变动记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JjyhUservalidays jjyhUservalidays)
    {
        return toAjax(jjyhUservalidaysService.updateJjyhUservalidays(jjyhUservalidays));
    }

    /**
     * 删除用户有效期变动记录
     */
    @RequiresPermissions("jjyh:uservalidays:remove")
    @Log(title = "用户有效期变动记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jjyhUservalidaysService.deleteJjyhUservalidaysByIds(ids));
    }
}
